package com.fengye.algorithms.leecode.dp;

/**
 * @Author fengye
 * @Date 2023/5/13 16:11
 **/
public class NThTribonacciNumber1137 {
    public static void main(String[] args) {
        new NThTribonacciNumber1137().tribonacci(4);
    }
    public int tribonacci(int n) {
        if(n<=1){
            return n;
        }

        if(n==2) {
            return 1;
        }

        int[] dp = new int[n+1];
        dp[1] = 1;
        dp[2] = 1;
        for(int i=3;i<=n;i++) {
            dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
        }
        return dp[n];
    }
}
